﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing.Design;
using System.Windows.Forms;
using System.ComponentModel;

namespace CommonClasses
{
    /// <summary>
    /// Редактор текстовых свойств (в модальном окне)
    /// </summary>
    public class TextValueEditor : UITypeEditor
    {
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            TextValueEditorForm form = new TextValueEditorForm();
            form.richTextBox.Text = value.ToString();
            form.Text = context.PropertyDescriptor.Description;
            form.ShowDialog();           
            return base.EditValue(context, provider, value);
        }

        public override void PaintValue(PaintValueEventArgs e)
        {
            return;
        }

        public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
        {
            return UITypeEditorEditStyle.Modal;
        }

        public override bool GetPaintValueSupported(ITypeDescriptorContext context)
        {
            return false;
        }
    }
}
